#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<math.h>
int main()
{
    int num = 0;
    int n = 0;
    int i = 0;
    int j = 0;  
    scanf("%d",&n);
    for (i = 2; i <= n; i++)
    {
        num = 1;
        for (j = 2; j <= sqrt(i); j++)
        {
            if (i % j == 0)
            {
                num += j;
                if (j != sqrt(i))
                {
                    num += i / j;
                }
            }
        }
        if (num == i)
        {
            printf("%d ",i);
        }
    }
    return 0;
}